#pragma once

#ifndef SNOWFLAKE_H
#define SNOWFLAKE_H
#include <QtGlobal>
#include <QObject>
#include "singleton.h"

class Snowflake: public QObject
{
    Q_OBJECT
public:
    SINGLETON(Snowflake);
    Snowflake();
    Snowflake(quint64 workerId);
    quint64 generateId();

private:
    quint64 workerId;
    quint64 sequence;
    quint64 lastTimestamp;
    quint64 getCurrentTimestamp();
    quint64 tilNextMillis(quint64 lastTimestamp);



};

#endif // SNOWFLAKE_H
